// 分析概览
import React, { PureComponent } from 'react';
import ProfitOverview from '../../../performanceAnalysis/profitOverview/ProfitOverview';
export default class AnalysisOverview extends PureComponent {
  static defaultProps = {
    onRef: () => {}, // 本组件的引用
  };
  constructor(props) {
    super(props);
    this.state = {};
  }
  componentDidMount() {
    //监听浏览器窗口变化 得到屏幕大小
    window.addEventListener('resize', this.windowChange);
    this.windowChange();
  }

  UNSAFE_componentWillReceiveProps() {}
  windowChange = () => {
    //监听当前组件的宽度
    if (document.getElementById('myPortAnalysis')) {
      let width = document.getElementById('myPortAnalysis').clientWidth;
      this.setState({
        isFloatLeft: width < 1243,
      });
    }
  };
  componentWillUnmount() {
    // 删除窗口大小的监听
    window.removeEventListener('resize', this.windowChange);
  }
  render() {
    return (
      <div>
        <ProfitOverview
          productCode={this.props.productCode}
          type='barra'
          portfolioType={this.props.portfolioType}
          isFloatLeft={this.state.isFloatLeft} //是否悬浮显示左侧菜单
          flag={this.props.flag} // 基准类别
          indexCode={this.props.indexCode} // 基准id
        />
      </div>
    );
  }
}
